package com.itheima.tanhua.member.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
* @author wuyunbin
*/
@Configuration
public class RedisTemplateConfig {
   //解析乱码
   @Bean
   @ConditionalOnSingleCandidate
   public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
       RedisTemplate<Object, Object> redisTemplate = new RedisTemplate();
       redisTemplate.setConnectionFactory(redisConnectionFactory);
       //StringRedisTemplate 使用的KeySerializer 移植过来
       redisTemplate.setKeySerializer(new StringRedisSerializer());

       return redisTemplate;

   }


}